﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace WF.Web.Classes
{
    public class CCHRPageBase<T> : Page, IDataItemContainer, IViewModelPage where T : IDataItemContainer, new()
    {
        protected T _vm;
        public CCHRPageBase() { _vm = new T(); }

        protected override void OnPreRender(EventArgs e)
        {
            this.DataBind();
            base.OnPreRender(e);

        }

        #region DataBinding
        public object DataItem
        {
            get { return _vm; }
        }

        public int DataItemIndex
        {
            get { return _vm.DataItemIndex; }
        }

        public int DisplayIndex
        {
            get { return _vm.DisplayIndex; }
        }
        #endregion

        public object GetViewModel()
        {
            return _vm;
        }
    }
}